<template>
  <div class="bgimg">
    <img
      src="https://img.zcool.cn/community/01738d5cdbd414a801214168da7eec.jpg@3000w_1l_0o_100sh.jpg"
      alt=""
    >
  </div>
  <div class="payment">
    <div class="payment-body">
      <el-alert
        title="所得收益将存于流浪动物基金，感谢您为流浪动物贡献一份爱心！"
        type="success"
      />
      <div
        class="card"
        v-for="item in shopData"
        :key="item.id"
      >
        <div class="img"><img
            :src="item.images"
            alt=""
          ></div>
        <div class="card-body">
          <div class="title">{{item.title}}
            <div class="pice">￥{{ item.pic }}</div>
            <div class="shu"><el-input-number
                v-model="num1"
                size="small"
              /></div>
          </div>
          <div class="zong"><label>总金额：</label>￥{{parseFloat(num1 * (item.pic).slice(1)).toFixed(2)}}</div>
        </div>
      </div>
      <form action="">
        <input
          type="name"
          placeholder="收件人"
        >
        <input
          type="phone"
          placeholder="联系电话"
        >
        <input
          type="address"
          placeholder="收件地址"
        >

      </form>
      <div
        class="btn"
        @click="yes"
      >确认支付</div>
    </div>
  </div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
const num1 = ref(1)
const money = ref(0)
import { useRouter } from 'vue-router'
const router = useRouter()
import axios from 'axios'
const shopData = ref([])
onMounted(() => {
  // console.log(router.query.commodityId)

  let api = 'https://apifoxmock.com/m1/4457699-4103776-default/api/catShop'
  axios.get(api).then((res) => {
    for (let i = 0; i < res.data.length; i++) {
      if (res.data[i].id == sessionStorage.getItem('commodityId')) {
        shopData.value[0] = res.data[i]
      }
    }
  })
})
function yes() {
  alert('支付成功,点击确认跳转到首页')
  router.push({ path: '/' })
}
</script>
<style scoped>
:focus {
  outline: none;
}
.payment {
  padding: 10px 15%;
  width: 100%;
  background-color: #eeeeee;
}
.payment-body {
  background-color: #fff;
  padding-bottom: 15px;
}
.payment-body .card {
  padding: 0 30px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.payment .card .img {
  width: 30%;
}

.payment .img img {
  width: 80%;
}
.payment .card-body {
  width: 70%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.payment .card-body .title {
  font-weight: 600;
  font-size: 1.2rem;
}
.payment .title .pice {
  margin-top: 30px;
  font-weight: 600;
}
.payment .title .shu {
  margin-top: 30px;
}
.payment .card-body .zong label {
  font-size: 1.1rem;
  font-weight: 600;
}
.payment .card-body .zong {
  margin-right: 40px;
  font-weight: 600;
  margin-top: 30px;
}
.payment-body form {
  padding: 10px;
  margin: auto;
  width: 80%;
}
.payment-body form input {
  width: 100%;
  padding: 10px;
  margin: 10px 0;
  border: 1px solid #cfcfcf;
}
.payment-body .btn {
  margin: 20px auto;
  padding: 10px;
  width: 150px;
  text-align: center;
  color: #fff;
  font-weight: 600;
  letter-spacing: 5px;
  text-align: center;
  border-radius: 20px;
  background: linear-gradient(-45deg, #ffd500, #69b45a, #5ecc52, #ffff00);
  background-size: 400% 400%;
  -webkit-animation: Gradient 10s ease infinite;
  -moz-animation: Gradient 10s ease infinite;
  animation: Gradient 10s ease infinite;
}
.payment-body .btn:hover {
  cursor: pointer;
}
@-webkit-keyframes Gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@-moz-keyframes Gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes Gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@media (max-width: 700px) {
  .payment {
    padding: 0;
  }
  .payment .card .img,
  .payment-body,
  .payment-body .card-body,
  .payment-body .title,
  .payment .title .pice,
  .payment .title .shu,
  .payment .card-body .zong {
    width: 100%;
    text-align: center;
  }
}
</style>